package Practice;

import java.util.Arrays;
import java.util.Scanner;

public class heartache {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int[] t = new int[n-m+1];
        for (int i = 0; i < n - m + 1; i++) {
            for (int j = i; j < i+m; j++) {
                t[i] += a[j];
            }
        }

        Arrays.sort(t);//给数组从小到大排序
        System.out.println(t[0]);
    }
}
